// components/mytab/mytab.js
const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    tablist: [],
    // dot:1
    tabindex:0
  },
  attached() {
  



  },
  ready() {
  },
  pageLifetimes: {
    show: function () {
      // console.log(this.data)
    },
    hide: function () {},
    resize: function () {},
  },
  /**
   * 组件的方法列表
   */
  methods: {
    switchTab(e) {

      // 判断是否有登录
      if (app.globalData.isLogin == '') {
        wx.navigateTo({
          url: '/pages/login/login',
        })
        return
      }

      if (wx.getStorageSync('isLogin')==2) {
        if( e.currentTarget.dataset.index==1){
          wx.navigateTo({
            url: '/pages/login/login',
          })
          return
        }
      }





      let t = this
      let index = e.currentTarget.dataset.index
      if((this.data.identity==5||this.data.identity==6)&&this.data.tablist[index].isUnplone){
        
      }else{
        app.globalData.tabindex = index
      }
      wx.setStorageSync('istab', true)
      if (this.data.tablist[index].isUnplone) {
        wx.navigateTo({
          url: "/" + this.data.tablist[index].pagePath,
       
        })
      } else {
        wx.switchTab({
          url: "/" + this.data.tablist[index].pagePath,
          success() {
          
          }
        })
      }
  
    },
    gettabList() {

      



      if(wx.getStorageSync('isLogin')==''||wx.getStorageSync('isLogin')==2){
        this.setData({
          tablist: [{
              title: "主页",
              iconPath: "/images/tabicon/home.png",
              selectedIconPath: "/images/tabicon/homeActive.png",
              pagePath: "pages/index/index",
            },
            {
              title: "我的",
              iconPath: "/images/tabicon/my.png",
              selectedIconPath: "/images/tabicon/myActive.png",
              pagePath: "pages/my/my",
            }
          ]
        })
        return
      }



      this.setData({
        tabindex: app.globalData.tabindex,
        identity:app.globalData.identity
      })
    
       let identity= app.globalData.identity
       console.log(app.globalData.identity)
      if (identity == 0) {
        this.setData({
          tablist: [{
              title: "主页",
              iconPath: "/images/tabicon/home.png",
              selectedIconPath: "/images/tabicon/homeActive.png",
              pagePath: "pages/index/index",
            },
            {
              title: "我的",
              iconPath: "/images/tabicon/my.png",
              selectedIconPath: "/images/tabicon/myActive.png",
              pagePath: "pages/my/my",
            }
          ]
        })
      } else if (identity == 1 || identity == 2 || identity == 3) {
        this.setData({
          tablist: [{
              title: "主页",
              iconPath: "/images/tabicon/home.png",
              selectedIconPath: "/images/tabicon/homeActive.png",
              pagePath: "pages/index/index",
            },
            {
              title: "团队",
              iconPath: "/images/tabicon/team.png",
              selectedIconPath: "/images/tabicon/teamActive.png",
            
              pagePath: "pages/team/team",
            },
            {
              title: "我的",
              iconPath: "/images/tabicon/my.png",
              selectedIconPath: "/images/tabicon/myActive.png",
              pagePath: "pages/my/my",
            },

          ]
        })
      } else if (identity == 4) {
        this.setData({
          tablist: [{
              title: "主页",
              iconPath: "/images/tabicon/home.png",
              selectedIconPath: "/images/tabicon/homeActive.png",
              pagePath: "pages/index/index",
            },
            {
              title: "团队",
              iconPath: "/images/tabicon/team.png",
              selectedIconPath: "/images/tabicon/teamActive.png",
            
              pagePath: "pages/team/team",
            },
            {
              title: "项目",
              //      选中
              iconPath: "/images/tabicon/project.png",
              selectedIconPath: "/images/tabicon/activeProject.png",
              pagePath: "pages/project/project",
            },
            {
              title: "我的",
              iconPath: "/images/tabicon/my.png",
              selectedIconPath: "/images/tabicon/myActive.png",
              pagePath: "pages/my/my",
            },

          ]
        })
      } else if (identity == 5||identity==10) {
        this.setData({
          tablist: [{
              title: "主页",
              iconPath: "/images/tabicon/home.png",
              selectedIconPath: "/images/tabicon/homeActive.png",
              pagePath: "pages/index/index",
            },
            {
              title: "项目",
              //      选中
              iconPath: "/images/tabicon/project.png",
              selectedIconPath: "/images/tabicon/activeProject.png",
              pagePath: "pages/project/project",
            },
            {
              title: "创建订单",
              iconPath: "/images/tabicon/add.png",
              selectedIconPath: "/images/tabicon/add.png",
              // 
              pagePath: "shopowner/pages/addpeople/addpeople?todo=addcustomer",
              isUnplone: true
            },
            {
              title: "团队",
              iconPath: "/images/tabicon/team.png",
              selectedIconPath: "/images/tabicon/teamActive.png",
            
              pagePath: "pages/team/team",
            },
            {
              title: "我的",
              iconPath: "/images/tabicon/my.png",
              selectedIconPath: "/images/tabicon/myActive.png",
              pagePath: "pages/my/my",
            },
         
          ]
        })
      } else if (identity == 6) {
        this.setData({
          tablist: [{
              title: "主页",
              iconPath: "/images/tabicon/home.png",
              selectedIconPath: "/images/tabicon/homeActive.png",
              pagePath: "pages/index/index",
            },
            {
              title: "项目",
              //      选中
              iconPath: "/images/tabicon/project.png",
              selectedIconPath: "/images/tabicon/activeProject.png",
              pagePath: "pages/project/project",
            },
            {
              title: "我的",
              iconPath: "/images/tabicon/my.png",
              selectedIconPath: "/images/tabicon/myActive.png",
              pagePath: "pages/my/my",
            },
            {
              title: "上传照片",
              iconPath: "/images/tabicon/add.png",
              selectedIconPath: "/images/tabicon/add.png",
              // pagePath: "pages/my/my",
              pagePath: "bricklayer/pages/orderList/orderList",
              isUnplone: true
            },
          ]
        })
      } else if (identity == 7||identity == 9) {
        this.setData({
          tablist: [{
              title: "主页",
              iconPath: "/images/tabicon/home.png",
              selectedIconPath: "/images/tabicon/homeActive.png",
              pagePath: "pages/index/index",
            },
            {
              title: "我的家",
              iconPath: "/images/tabicon/myhome.png",
              selectedIconPath: "/images/tabicon/activemyhome.png",
              pagePath: "pages/myHome/myHome",
              isclass:true
            },
            {
              title: "我的",
              iconPath: "/images/tabicon/my.png",
              selectedIconPath: "/images/tabicon/myActive.png",
              pagePath: "pages/my/my",
            },
          ]
        })
      } else if (identity == 8) {
        this.setData({
          tablist: [{
              title: "主页",
              iconPath: "/images/tabicon/home.png",
              selectedIconPath: "/images/tabicon/homeActive.png",
              pagePath: "pages/index/index",
            },

            {
              title: "项目",
              //      选中
              iconPath: "/images/tabicon/project.png",
              selectedIconPath: "/images/tabicon/activeProject.png",
              pagePath: "pages/project/project",
            },
            {
              title: "我的",
              iconPath: "/images/tabicon/my.png",
              selectedIconPath: "/images/tabicon/myActive.png",
              pagePath: "pages/my/my",
            }
          ]
        })
      }
    
    }
    


  }
})